using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using AspWebUtilities.Farm;
using System.Threading;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //FarmApplication.RunOnCriticalSection(
        //delegate()
        //{
        //    FarmApplication.Application.LockForServer("Data_0");
        //    ValueText.Text = (String)FarmApplication.Application["Data_0"];
        //    FarmApplication.Application.UnlockForServer("Data_0");
        //}
        //    );

    }
    protected void SaveAsString_Click(object sender, EventArgs e)
    {
        FarmApplication.RunOnCriticalSection(new String[] { "Data_0" },
        delegate()
        {
            FarmApplication.Application["Data_0"] = TestString.Text;
        }
       );
    }
    protected void LoadAsString_Click(object sender, EventArgs e)
    {
        FarmApplication.RunOnCriticalSection(new String[]{"Data_0"},
        delegate()
        {
            TestString.Text = (String)FarmApplication.Application["Data_0"];
        }
       );
    }
    protected void SaveAsInt_Click(object sender, EventArgs e)
    {
        FarmApplication.RunOnCriticalSection(new string[]{"Data_1"},
        delegate()
        {
            FarmApplication.Application["Data_1"] = Convert.ToInt16(TestInt.Text);
        }
       );
    }
    protected void LoadAsInt_Click(object sender, EventArgs e)
    {
        FarmApplication.RunOnCriticalSection(new String[]{"Data_1"},
        delegate()
        {
            TestInt.Text = Convert.ToString(FarmApplication.Application["Data_1"]);
        }
       );
    }
    protected void LoadAsDouble_Click(object sender, EventArgs e)
    {
        FarmApplication.RunOnCriticalSection(new String[]{"Data_2"},
        delegate()
        {
            TestDouble.Text = Convert.ToString(FarmApplication.Application["Data_2"]);
        }
       );
    }
    protected void SaveAsDouble_Click(object sender, EventArgs e)
    {
        FarmApplication.RunOnCriticalSection(new String[]{"Data_2"},
        delegate()
        {
            FarmApplication.Application["Data_2"] = Convert.ToDouble(TestDouble.Text);
        }
       );
    }
}
